package com.ynny.date01;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Random;

public class DateDemo01 {

    public static void main(String[] args) {

        //JDK8之前
        Date date = new Date();
        System.out.println(date);

        //JDK8之后
        //
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);

        //日期格式化
        //
        DateTimeFormatter dateTimeFormatter =
                DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");

        System.out.println(dateTimeFormatter.format(LocalDateTime.now()));



        //随机数
        Random random = new Random();
//        int res = random.nextInt();//int 范围内的随机数

        for (int i = 0; i < 10; i++) {
            int res = random.nextInt(10) + 1;
            System.out.println(res);
        }


    }
}
